using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace DeadLinkChecker
{
    class DeadLinkCheckerFeatureReceiver : SPFeatureReceiver
    {
        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;

            SPList bllist = null;
            try
            {
                bllist = site.RootWeb.GetList("/Lists/BrokenLinks");
            }
            catch
            {
                bllist = null;
            }

            if (bllist == null)
            {
                Guid blguid = site.RootWeb.Lists.Add("BrokenLinks", "Broken links", SPListTemplateType.GenericList);
                bllist = site.RootWeb.Lists[blguid];
                bllist.Fields.Add("Referer", SPFieldType.Text, true);
                bllist.Fields.Add("Problem", SPFieldType.Text, true);
                bllist.Update();
            }
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {

        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {

        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {

        }
    }
}
